<template>
  <div id="newcomer-reward">
    <c-title :hide="false" text="奖励记录"></c-title>
    <van-tabs v-model:active="active" class="tabs-style" @change="changeTabs" title-active-color="#f14e4e" color="#f14e4e">
      <van-tab :title="cItem.title" :name="cItem.id" v-for="(cItem, cIndex) in vanTab" :key="cIndex">
        <d-list :loading="loading" :finished="finished" @load="onLoad">
          <div>
            <div class="box" v-for="(item, indx) in newcomerReward" :key="index" v-if="active == cItem.id">
              <div class="top">
                <div class="top-time">
                  <div class="reward-time">{{ item.created_at }}</div>
                  <span class="status">{{ item.status_name }}</span>
                </div>
                <div class="top-title">
                  <div class="member" v-if="item.has_one_buyer !== null">
                    <img :src="item.has_one_buyer.avatar_image" alt="" />
                    <div class="member-detail">
                      <span class="member-name">{{ item.has_one_buyer.nickname }}</span>
                      <span class="member-id">id: {{ item.has_one_buyer.uid }}</span>
                    </div>
                  </div>
                  <div class="right-status" v-if="item.has_one_buyer !== null">
                    <span class="num">{{ item.type_name }}</span>
                    <span class="num">{{ item.record_sort }}</span>
                  </div>
                </div>
                <div class="desc-detail">
                  <span class="desc-name">{{ item.has_one_activity&&item.has_one_activity.name }}</span>
                  <span class="desc-sn" v-if="item.order_sn">{{ item.order_sn }}</span>
                  <div class="right-status desc-name-status" v-if="item.has_one_buyer == null && !item.order_sn">
                    <span class="num">{{ item.type_name }}</span>
                    <span class="num">{{ item.record_sort }}</span>
                  </div>
                </div>
              </div>
              <div class="middle-line"></div>
              <div class="bottom">
                <div class="top-goods" v-if="item.has_one_goods !== null">
                  <img :src="item.has_one_goods !== null ? item.has_one_goods.thumb : ''" alt="" />
                  <div class="detail">
                    <span class="goods-name">{{ item.has_one_goods !== null ? item.has_one_goods.title : "" }}</span>
                    <!-- <span class="goods-num">第2件商品</span> -->
                  </div>
                </div>
                <div class="bottom-money">
                  <div class="money-box">
                    <span class="num">{{ item.rewards_amounts }}</span>
                    <span class="status-name">{{ fun.getBalanceLang() }}</span>
                  </div>
                  <div class="money-box">
                    <span class="num">{{ item.rewards_income }}</span>
                    <span class="status-name">收入</span>
                  </div>
                  <div class="money-box">
                    <span class="num">{{ item.rewards_points }}</span>
                    <span class="status-name">{{ fun.getCustomTextLang('member_center.credit1','积分') }}</span>
                  </div>
                  <div class="money-box">
                    <span class="num">{{ item.rewards_coupons }}张</span>
                    <span class="status-name">优惠券</span>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </d-list>
      </van-tab>
    </van-tabs>
  </div>
</template>
<script>
import newcomer_reward from "./newcomer_reward";

export default newcomer_reward;
</script>
<style lang="scss" rel="stylesheet/scss" scoped>
#newcomer-reward {
  .box {
    background: white;
    margin: 0.63rem;
    border-radius: 0.31rem;
    padding: 0.86rem 0.81rem 0.63rem 0.63rem;

    .top {
      text-align: left;

      .top-time {
        display: flex;
        justify-content: space-between;
        margin-bottom: 0.46rem;

        .status {
          font-size: 0.75rem;
          font-weight: normal;
          font-stretch: normal;
          color: #f15353;
        }
      }

      .top-title {
        display: flex;
        justify-content: space-between;
        margin-bottom: 0.94rem;

        .member {
          display: flex;

          img {
            width: 1.96rem;
            height: 1.96rem;
            border-radius: 50%;
            margin: 0 0.41rem 0 0;
          }

          .member-detail {
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            line-height: 1;

            .member-name {
              font-size: 0.75rem;
              font-weight: normal;
              font-stretch: normal;
              color: #353535;
            }

            .member-id {
              font-size: 0.63rem;
              font-weight: normal;
              font-stretch: normal;
              color: #686868;
            }
          }
        }
      }

      .right-status {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        align-items: flex-end;
        line-height: 1;

        .num {
          font-size: 0.63rem;
          font-weight: normal;
          font-stretch: normal;
          color: #686868;
        }
      }

      .desc-name-status {
        line-height: 1.5;
      }

      .desc-detail {
        display: flex;
        justify-content: space-between;
        margin-bottom: 0.63rem;

        .desc-name {
          font-size: 0.81rem;
          font-weight: normal;
          font-stretch: normal;
          color: #353535;
          width: 50%;
        }

        .desc-sn {
          font-size: 0.69rem;
          font-weight: normal;
          font-stretch: normal;
          color: #686868;
          word-break: break-all;
          width: 50%;
          text-align: right;
        }
      }

      .reward-time {
        font-size: 0.63rem;
        font-weight: normal;
        font-stretch: normal;
        color: #9e9e9e;
      }
    }

    .middle-line {
      width: 100%;
      height: 0.06rem;
      background-color: #f2f2f2;
      margin: 0.72rem 0;
    }

    .bottom {
      text-align: left;

      .top-goods {
        display: flex;

        img {
          width: 2.48rem;
          height: 2.48rem;
          border-radius: 0.13rem;
          margin: 0 0.31rem 0 0;
        }

        .detail {
          display: flex;
          flex-direction: column;
          justify-content: space-between;

          .goods-name {
            font-size: 0.75rem;
            font-weight: normal;
            font-stretch: normal;
            color: #353535;
          }

          .goods-num {
            font-size: 0.63rem;
            font-weight: normal;
            font-stretch: normal;
            color: #686868;
          }
        }
      }

      .bottom-money {
        display: flex;
        background: rgba(241, 83, 83, 0.1);
        border-radius: 0.31rem;
        justify-content: space-around;
        margin-top: 0.69rem;
        padding: 0.69rem 0 0.59rem 0;

        .money-box {
          display: flex;
          flex-direction: column;
          text-align: center;

          .num {
            font-size: 0.75rem;
            font-weight: bold;
            font-stretch: normal;
            line-height: 1;
            color: #f14e4e;
            margin-bottom: 0.78rem;
          }

          .status-name {
            font-size: 0.63rem;
            font-weight: bold;
            font-stretch: normal;
            line-height: 1;
            color: #3d3d3d;
          }
        }
      }
    }
  }
}
</style>
